var a = getApp();

Page({
  data: {
    click: "",
    classname: "submit1",
    successFlag: !1,
    show: !0,
    value: "",
    base: "",
    interest1: !0,
    interest2: !1,
    interest3: !1,
    rate: 0,
    ofrate: 0,
    name: 1,
    arr:{
      defaultBankCard:'',
      bankName:''
    }
  },
  bank: function(a) {
    let that = this;
    console.log(1)
    let b = that.data.name;
    let c = that.data.arr.defaultBankCard.bankName;
    if(b==1){
      console.log(2)
      that.setData({
        name:2
      })
    }else{
      console.log(3)
      that.setData({
        name:1
      })
      if(!c){
        wx.navigateTo({
          url: "/hyb_yl/backstageServicess/pages/bank/bank"
        });
      }
    }   
  },
  input: function(a) {
    console.log(parseFloat(this.data.value)), console.log(this.data.rate), console.log(this.data.arr.moneyBag.money / 100),
      this.setData({
        value: a.detail.value
      }), this.data.value >= this.data.base ? (this.setData({
        classname: "submit",
        click: "click",
        interest3: !0,
        interest1: !1,
        interest2: !1,
        ofrate: (this.data.value * this.data.rate).toFixed(2)
      }), parseFloat(this.data.value) > this.data.arr.moneyBag.money / 100 && this.setData({
        interest3: !1,
        interest1: !1,
        interest2: !0,
        classname: "submit1",
        click: ""
      })) : this.data.value < this.data.base && this.setData({
        interest3: !1,
        interest1: !0,
        interest2: !1,
        classname: "submit1",
        click: ""
      });
  },
  click: function(a) {
    var t = wx.getStorageSync("money") || "";
    1 == t ? (console.log("个人提现"), this.form()) : 2 == t && (console.log("团队提现"), this.form1());
  },
  form: function(t) {
    var e = this,
      o = e.data.arr.moneyBag.money;
    e.data.value <= o ? wx.request({
      url: a.globalData.dic + "doctor/withdraw/bank/withdrawDeposit",
      data: {
        token: wx.getStorageSync("log") || "",
        bankId: e.data.arr.defaultBankCard.id,
        money: parseInt(100 * e.data.value)
      },
      method: "POST",
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      success: function(a) {
        console.log(a.data.data), 200 == a.data.code && e.setData({
          successFlag: !0,
          text: a.data.data
        });
      }
    }) : wx.showToast({
      title: "余额不足",
      icon: "none",
      duration: 2e3
    });
  },
  form1: function(t) {
    var e = this,
      o = e.data.arr.moneyBag.money,
      s = wx.getStorageSync("teamId") || "";
    e.data.value <= o ? wx.request({
      url: a.globalData.dic + "doctor/team/withdraw/bank/withdrawDeposit",
      data: {
        token: wx.getStorageSync("log") || "",
        bankId: e.data.arr.defaultBankCard.id,
        money: parseInt(100 * e.data.value),
        teamId: s
      },
      method: "POST",
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      success: function(a) {
        console.log(a.data.data), 200 == a.data.code && e.setData({
          successFlag: !0,
          text: a.data.data
        });
      }
    }) : wx.showToast({
      title: "余额不足",
      icon: "none",
      duration: 2e3
    });
  },
  goodBtn: function(a) {
    this.setData({
      successFlag: !1
    }), wx.navigateBack({
      delta: 1
    });
  },
  onLoad: function(a) {},
  onShow: function() {
    var a = wx.getStorageSync("money") || "";
    1 == a ? (console.log("个人提现"), this.onclick()) : 2 == a && (console.log("团队提现"),
      this.onclick1());
  },
  onclick: function(t) {
    var e = wx.getStorageSync("log") || "",
      o = this;
    wx.request({
      url: a.globalData.dic + "doctor/withdraw/bank/toWithdrawDeposit",
      data: {
        token: e
      },
      success: function(a) {
        console.log(a.data.data), wx.setStorageSync("clientsOfBanks", a.data.data.name),
          null == a.data.data.defaultBankCard ? o.setData({
            show: !1
          }) : o.setData({
            show: !0
          }), o.setData({
            arr: a.data.data,
            base: a.data.data.config.base / 100,
            rate: a.data.data.config.taxRate
          });
      }
    });
  },
  onclick1: function(t) {
    var e = wx.getStorageSync("log") || "",
      o = wx.getStorageSync("teamId") || "",
      s = this;
    wx.request({
      url: a.globalData.dic + "doctor/team/withdraw/bank/toWithdrawDeposit",
      data: {
        token: e,
        teamId: o
      },
      success: function(a) {
        console.log(a.data.data), wx.setStorageSync("clientsOfBanks", a.data.data.name),
          null == a.data.data.defaultBankCard ? s.setData({
            show: !1
          }) : s.setData({
            show: !0
          }), s.setData({
            arr: a.data.data,
            base: a.data.data.config.base / 100,
            rate: a.data.data.config.taxRate
          });
      }
    });
  },
  all: function(a) {
    var t = this,
      e = t.data.arr.moneyBag.money;
    console.log(e), t.setData({
      value: e / 100
    }), t.data.value >= this.data.base ? t.setData({
      classname: "submit",
      click: "click",
      interest3: !0,
      interest1: !1,
      interest2: !1,
      ofrate: (this.data.value * this.data.rate).toFixed(2)
    }) : t.setData({
      classname: "submit1",
      click: ""
    });
  }
});